﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace lcmyjobs.Web.users
{
    public partial class user_adv : BasePage
    {
        lcmyjobs.BLL.user_basic bub = new BLL.user_basic();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.Title = string.Format("个人管理中心—悬赏&bull;猎头服务：猎头服务   {0}", Application["webname"].ToString());
                if (Session["user_id"] != null)
                {
                    int id = int.Parse(Session["user_id"].ToString());
                    this.lblName.Text = Session["user_name"].ToString();
                    getadv(id);
                }
                else
                {
                    Response.Redirect("userlogin.html");
                }
            }


        }
        protected void getadv(int id)
        {
            float r = 0;
            r = bub.getadv(id);
            hfvalue.Value = r.ToString();
            if (r == 0)
            {
                lblstatus.Text = "你还没有申请猎头服务";
                txtadd.Text = "";
                txtupdate.Text = "";

                this.lblhint.Text = "您是高级人才：硕士及以上学历、或具有年薪5万以上的工作能力、或小语种外语人才等，建议您申请猎头服务，您将有机会被我就业网猎头服务 推荐猎头职位<br />";

            }
            else
            {
                lblstatus.Text = "你已申请猎头服务 年薪：" + r.ToString() + "万元";
                this.lblhint.Text = "您是高级人才，申请猎头服务，您有机会被 我就业网猎头服务 推荐猎头职位<br />";
            }

        }

        protected void btndel_Click(object sender, EventArgs e)
        {
            if (Session["user_id"] != null)
            {
                int id = int.Parse(Session["user_id"].ToString());
                bub.deleteadv(id);
                getadv(id);
            }
            else
            {
                Response.Redirect("userlogin.html");
            }

        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (Session["user_id"] != null)
            {
                int id = int.Parse(Session["user_id"].ToString());
                try
                {
                    float i = float.Parse(txtadd.Text);
                    if (i != 0f)
                    {
                        int r = bub.updateadv(id, i);
                        if (r == 0)
                        {
                            Maticsoft.Common.MessageBox.Show(this, "更新失败！");

                        }
                    }

                    getadv(id);
                }
                catch (Exception ex)
                {

                    Maticsoft.Common.MessageBox.Show(this, "更新失败！");
                }
            }
            else
            {
                Response.Redirect("userlogin.html");
            }



        }

        protected void btnupdate_Click(object sender, EventArgs e)
        {
            if (Session["user_id"] != null)
            {
                int id = int.Parse(Session["user_id"].ToString());
                try
                {
                    float i = float.Parse(txtupdate.Text);
                    if (i != 0f)
                    {
                        int r = bub.updateadv(id, i);
                        if (r == 0)
                        {
                            Maticsoft.Common.MessageBox.Show(this, "更新失败！");
                        }
                    }

                    getadv(id);
                }
                catch (Exception ex)
                {

                    Maticsoft.Common.MessageBox.Show(this, "更新失败！");
                }
            }
            else
            {
                Response.Redirect("userlogin.html");
            }


        }
    }
}